package com.android.pagemarket.ui.activity.price;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;

import com.android.pagemarket.R;
import com.android.pagemarket.business.model.Paper.Price;
import com.android.pagemarket.ui.activity.base.TemplateActivity;
import com.android.pagemarket.ui.adapter.BrandListAdapter;
import com.android.pagemarket.ui.widget.TitleBar;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-11-2
 * @see : 材质详情视图
 * @Copyright : copyrights reserved by personal 2007-2011
 **********************************************************/
public class MaterialDetailActivity extends TemplateActivity
{
    private Price mPaper;
    private BrandListAdapter listAdapter;
    
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        if(!handIntent())
        {
            finish();
            return;
        }
        setContentView(R.layout.activity_materialdetail);
        initViews();
    }
    
    @Override
    protected void setupTitleBar(TitleBar titleBar)
    {
        titleBar.setTitle(R.string.title_material);
        titleBar.setRightVisible(false);
    }
    
    private void initViews()
    {       
        ListView listView = getViewById(R.id.listView);
        listAdapter = new BrandListAdapter(this);
        listView.setAdapter(listAdapter);
        
        listAdapter.setList(mPaper.brandList);
    }
    
    private boolean handIntent()
    {
        Intent it = getIntent();
        mPaper = (Price)it.getSerializableExtra(KEY_PARAM);
        return mPaper != null;
    }
    
    public static void startActivity(Context context, Price paper)
    {
        Intent it = new Intent(context, MaterialDetailActivity.class);
        it.putExtra(KEY_PARAM, paper);
        context.startActivity(it);
    } 
}
